#!/usr/bin/env node

const fs = require('fs');
const path = require('path');

const dir = process.argv[2];

// 检查是否提供了目录名
if (!dir) {
    console.error('Error: No directory name provided.');
  } else {
    // 使用绝对路径创建目录
    const absoluteDir = path.resolve(__dirname, dir);
  
    // 检查目录是否已经存在
    if (fs.existsSync(absoluteDir)) {
      console.error(`Error: Directory "${absoluteDir}" already exists.`);
    } else {
      // 创建目录
      try {
        fs.mkdirSync(absoluteDir, { recursive: true });
        console.log(`Directory "${absoluteDir}" created successfully.`);
      } catch (error) {
        console.error(`Error: Unable to create directory "${absoluteDir}": ${error.message}`);
      }
    }
  }